{extend name="public:_base" /}
{block name="css"}
{CSS href="__STATIC__/w/admin_base.css" /}
{CSS href="__STATIC__/w/layui.css" /}
{CSS href="__STATIC__/w/divtable.css" /}
{/block}
{block name="js"}
{js href='__STATIC__/w/layui.js' /}
{/block}

{block name="main"}

<div class="layui-form-cont">
    中奖人数：{$count} 个　　已发奖品：{$sendstutas}个
    <a href="{:url(\''.\\think\\Request::instance()->controller().'/exportSN',['id'=>$Request.param.id])}" class="btnGrayS">导出Excel中奖数据</a>

    <div class="layui-tab-nav" style="display: none">

            <ul class="layui-tab-title">
                <li {eq name="$Request.param.islottery" value=""}class="layui-this"{/eq} >
                    <a href="{:url(\''.\\think\\Request::instance()->controller().'/checkcode',['id'=>$Request.param.id])}">全部</a>
                </li>
                <li {eq name="$Request.param.islottery" value="1"}class="layui-this"{/eq} >
                <a href="{:url(\''.\\think\\Request::instance()->controller().'/checkcode',['islottery'=>'1','id'=>$Request.param.id])}">中奖</a>
                </li>
                <li {eq name="$Request.param.islottery" value="0"}class="layui-this"{/eq} >
                <a href="{:url(\''.\\think\\Request::instance()->controller().'/checkcode',['islottery'=>'0','id'=>$Request.param.id])}">不中奖</a>
                </li>
            </ul>
    </div>

        <div class="layui-tab-content layui-new-table">
            <table class="layui-table" lay-skin="line">
                <thead>
                <tr>
                    <th>奖项</th>
                    <th>SN码(中奖号)</th>
                    <th>是否已发奖品</th>
                    <th>奖品发送时间</th>
                    <th>中奖者手机号</th>
                    <th>中奖者微信码</th>
                    <th>中奖时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{:\\app\\admin\\controller\\Guajiang::getPrizeName($vo.lid,$vo.prize)}</td>
                    <td>{$vo.sn}</td>
                    <td>{$vo.sendstutas ?'是': ''}</td>
                    <td>{notempty name="$vo.sendtime"}{$vo.sendtime|date="Y-m-d",###}{/notempty}</td>
                    <td>{$vo.phone}</td>
                    <td>{$vo.wecha_name}</td>
                    <td>{$vo.time|date="Y-m-d",###}</td>
                    <td>{empty name="$vo.sendstutas" value="0"}
                        <a class="rha-bt-a" href="javascript:;" onclick="sendstutas('{$vo.id}',1)">发奖</a>
                        {else /}
                        <a class="rha-bt-a" href="javascript:;" onclick="sendstutas('{$vo.id}',0)">取消发奖</a>
                        {/empty}
                        <a class="rha-bt-a" href="javascript:;" onclick="delnewcode('{$vo.id}')">删除</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
        </div>
</div>
<script>
    //发奖
    function sendstutas(id,status) {
        $.post("{:url('sendstutas')}",{'id':id,'status':status},function (res) {
            if(res.status==1){
                layer.alert(res.msg);
                window.location.reload();
            }else{
                layer.alert(res.msg)
            }
        })
    }

    //删除
    function delnewcode(id) {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.confirm('你确定需要删除吗？', {
                btn: ['是','不'] //按钮
            }, function(){
                $.post("{:url('delrecord')}",{'id':id},function (res) {
                    if(res.status==1){
                        layer.alert(res.msg,function (index) {
                            window.location.reload();
                            layer.close(index);
                        })

                    }else{
                        layer.alert(res.msg)
                    }
                })
            }, function(){

            });
        });

    }
</script>
{/block}